using System;
using Gtk;

namespace DaphneTranslator
{
	public partial class CompleteTextDialog : Gtk.Dialog
	{
		public CompleteTextDialog ()
		{
			this.Build ();
			buttonCancel.Clicked += HandleCancel;
			buttonOk.Clicked += HandleOK;
		}

		void HandleOK (object sender, EventArgs e)
		{
			if (ValidateDialog () == false) {
				return;
			}
			
			Respond (ResponseType.Ok);			
		}
		
		public string GetText ()
		{
			return entryText.Text.Trim ();
		}                      		                     

		void HandleCancel (object sender, EventArgs e)
		{
			Respond (ResponseType.Cancel);			
		}
		
		private void ShowValidationMessageBox (string sMessage)
		{
			MessageDialog msg = new MessageDialog (this, DialogFlags.Modal, MessageType.Warning,
				                                      ButtonsType.Ok, sMessage);
			msg.Title = "Validation error";
			msg.Run ();		
			msg.Destroy ();						
		}
		
		private bool ValidateDialog ()
		{
			if (string.IsNullOrWhiteSpace (entryText.Text) == true) {
				ShowValidationMessageBox ("Please fill in the text for the primary langauge.");
				return false;
			}		
			
			return true;
		}	
		
		
	}
}

